package com.catazzz.springbootstudy.controller;


import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.catazzz.springbootstudy.common.exception.Result;
import com.catazzz.springbootstudy.entity.SysUser;
import com.catazzz.springbootstudy.entity.User;
import com.catazzz.springbootstudy.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 系统用户表 前端控制器
 * </p>
 *
 * @author Tao
 * @since 2025-01-07
 */
@Slf4j
@RestController
@RequestMapping("/sysUser")
@Api(tags = "系统用户")
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

//    @Autowired
//    private PasswordEncoder passwordEncoder;

    @ApiOperation(
            value = "更新用户密码",
            response = Boolean.class,
            httpMethod = "POST",
            produces = "application/json",
            consumes = "application/json",
            protocols = "http,https"
    )
    @PostMapping("/updatePassword")
    public Result<Boolean> updatePassword(@RequestParam String username,
                                          @RequestParam String password) {
//        String encodePw = passwordEncoder.encode(password);
//        log.info("username:{},password:{}", username, encodePw);
//        boolean update = sysUserService.update(
//                Wrappers
//                        .<SysUser>lambdaUpdate()
//                        .eq(SysUser::getUsername, username)
//                        .set(SysUser::getPassword, encodePw)
//        );
        return Result.success(true);
    }
}
